/**
 * 系统设置权限设置添加管理员
 */
import './index.less'
import tem from './index.html'
import $_fn from '~plugins'
class shiftCtrl {
  constructor($scope,$rootScope,http,$ui) {
  	  console.log($scope.params)
  	  $scope.loan_number=JSON.parse($scope.params).loan_number
      $scope.cancel = function () {
          $rootScope.$uiDirectiveModal.close() //关闭方法
      }
      //订单id
      console.log($scope.id)
  	  //初始化参数
  	  $scope.type1=JSON.parse($scope.params).loan_type
  	  $scope.param1={
  	  	oid:JSON.parse($scope.params).id
  	  }

  	//输入错误提示
  	$scope.err=function(datas){
  		$scope[datas]=true;
  		setTimeout(function() {
  			$scope[datas]=false;
  			$scope.$apply()
  		}, 1000);
  	}
  	//添加管理员提交
  	  $scope.tiJiao1=function(){
  	  		console.log('选择转入')
	  	  	if(!$scope.param1.transfer_type){
	  	  		$ui.toast({
					text:'请选择转入方式',
					type:'warning',
					appendTo:'.shift'
				})
	  	  		return 
	  	  	}
	  	  	if(!$scope.param1.transfer_remark){
	  	  		$ui.toast({
					text:'请输入备注',
					type:'warning',
					appendTo:'.shift'
				})
	  	  		return 
	  	  	}
	  	  	$scope.param1.fp_id=JSON.parse($scope.params).fp_id
  	  		http.post('toCollection.do',$scope.param1,function (data) {
				if(data.errcode==1){
					$ui.toast({
						text:data.errmsg,
						type:'succeed',
						appendTo:'.shift'
					})
					$scope.cancel()//关闭弹窗
					//window.history.go(0)
				}else{
					$ui.toast({
						text:data.errmsg,
						type:'warning',
						appendTo:'.shift'
					})
				}
	        },function(_data){
	            console.log(_data);//报错
	      	})
  	  }
  }
}
shiftCtrl.$inject = ['$scope','$rootScope','http','$ui']
module.exports = angular.module('directive.shift', []).directive('shift', function() {
    return {
        template: tem,
        replace:true,
        controller: shiftCtrl,
        scope:{
        	params:"@"
        }
    }
}).name